/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Navigator,
  StatusBar,
  BackAndroid
} from 'react-native';
import FirstPageComponent from './firstComponent';
import SecondPageComponent from './secondComponent';
import ThirdPageComponent from './thirdComponent';
import FourPageComponent from './fourComponent/FourPageComponent';
import { styles } from '../styles';

let globalNav = {};
export default class Android extends Component {
  constructor(props) {
      super(props);
      this.state = {
        nav:null
      }
  }
  onBackAndroid() {
    return false;
  }
  render() {
      const { position } = this.props;
      let defaultComponent = FirstPageComponent;
      let Component;
      let self = this;
      return(
        <View style={styles.flexColumn}>
          <StatusBar
             backgroundColor="#ccc"
             barStyle="light-content"
             hidden={true}
           />
          <Navigator initialRoute={{
              component: defaultComponent
          }} configureScene={(route) => {
              return Navigator.SceneConfigs.FadeAndroid;
          }} renderScene={(route, navigator) => {
              globalNav = navigator;
              BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid.bind(this));
              switch (position) {
                case 0:
                  Component = FirstPageComponent;
                  break;
                case 1:
                  Component = SecondPageComponent;
                  break;
                case 2:
                  Component = ThirdPageComponent;
                  break;
                default:
                  Component = FourPageComponent;
                  break;
              }
              return <Component {...route.params} navigator={navigator}/>
          }}/>
        </View>
      )
  }
}
